import React, { Component } from 'react'
import  {connect} from  "react-redux"
import  {addNum} from  "../action/numAction";
import  {changeFlag} from  "../action/flagAction"

class A4 extends Component<any,any> {
  render() {
    return (
      <div>A4

          <h1>全局数据{this.props.num}</h1>
          <button onClick={()=>{
              this.props.addNum(100);
          }}>修改</button>
      </div>
    )
  }
  componentDidMount(){
      this.props.changeFlag(false);
  }
  componentWillUnmount(){
      this.props.changeFlag(true);
  }

}

let  mapStateToProps = ({numInfo}:any)=>{
    return  {
        num:numInfo.num
    }
}
let  mapDispatchToProps  = {
    addNum,
    changeFlag
}

export  default  connect(mapStateToProps,mapDispatchToProps)(A4);//高阶组件
